<?php
/*if ($this->session->flashdata('message')){
	echo "<div class='message'>".$this->session->flashdata('message')."</div>";
}
else {
	echo "<p>Welcome to your page.</p>";
}*/
if ($this->session->flashdata('message')){
	echo "<div class='message'>".$this->session->flashdata('message')."</div>";
}
?>
<h1><?php echo $title;?></h1><br>
<?php
	// Pages
	$pages = $this->MPage->getAllPages();
	if ( count($pages) )
	{
		echo '<h2> Pages </h2><br>';
		echo '<table cellpadding="0" cellspacing="0" border="0" class="bordered-table zebra-striped" id="example">';
		echo "<thead>\n<tr valign='top'>\n";
		echo "<th>No</th>\n<th>Name</th><th>Full Path</th><th>Description</th><th>Activate</th><th>Actions</th>\n";
		echo "</tr>\n</thead>\n<tbody>\n";
		$i = 1;
		foreach ($pages as $key => $list){
			echo "<tr valign='top'>\n";
			echo "<td align='center'>".$i++."</td>\n";
			echo "<td align='center'>".$list['name']."</td>\n";
			echo "<td>";
	   		/*if (!preg_match("/\.html$/",$list['path'])){
	  			$list['path'] .= ".html";
	  		}*/		
			
			// if ($list['parent_id'] == 0){
				echo "/". $list['path'];
			/*}else{
				echo "/". $cats[$list['parent_id']]. "/". $list['path'];
			}*/
			echo "</td>";
			echo "<td align='center'>".$list['description']."</td>\n";
			
			if($list['activate']==1) 
				$activate = 'active';
			else 
				$activate = 'inactive';
				
			echo "<td align='center'>". $activate."</td>\n";
			echo "<td align='center'>";
			echo anchor('cadminpage/edit/'.$list['page_id'],'edit');
			echo " | ";
			echo anchor('cadminpage/delete/'.$list['page_id'],'delete',array('class'=>'delete-item'));
			echo "</td>\n";
			echo "</tr>\n";
		}
		echo "</tbody>\n</table>";
	}
	
	// News
	echo '<h2> News </h2><br>';
	$news = $this->MNews->getAllNews();
	if ( count($news) )
	{
		echo '<table cellpadding="0" cellspacing="0" border="0" class="bordered-table zebra-striped" id="example">';
		echo "<thead>\n<tr valign='top'>\n";
		echo "<th>No</th>\n<th>Title</th><th>Full Path</th><th>Short description</th><th>Activate</th><th>Actions</th>\n";
		echo "</tr>\n</thead>\n<tbody>\n";
		$i = 1;
		foreach ($news as $key => $list){
			echo "<tr valign='top'>\n";
			echo "<td align='center'>".$i++."</td>\n";
			echo "<td align='center'>".$list['title']."</td>\n";
			echo "<td>";
	   		if (!preg_match("/\.html$/",$list['path'])){
	  			$list['path'] .= ".html";
	  		}		
			echo "/". $list['path'];
			echo "</td>";
			echo "<td align='center'>".$list['shortdesc']."</td>\n";
			
			if($list['activate']==1) 
				$activate = 'active';
			else 
				$activate = 'inactive';
				
			echo "<td align='center'>". $activate."</td>\n";
			echo "<td align='center'>";
			echo anchor('cnews/edit/'.$list['news_id'],'edit');
			echo " | ";
			echo anchor('cnews/delete/'.$list['news_id'],'delete',array('class'=>'delete-item'));
			echo "</td>\n";
			echo "</tr>\n";
		}
		echo "</tbody>\n</table>";
	}
	
	// Events
	echo '<h2> Events </h2><br>';
	$events = $this->MEvent->getAllEvents();
	if ( count($events) )
	{
		echo '<table cellpadding="0" cellspacing="0" border="0" class="bordered-table zebra-striped" id="example">';
		echo "<thead>\n<tr valign='top'>\n";
		echo "<th>No</th>\n<th>Title</th><th>Full Path</th><th>Short description</th><th>Activate</th><th>Actions</th>\n";
		echo "</tr>\n</thead>\n<tbody>\n";
		$i = 1;
		foreach ($events as $key => $list){
			echo "<tr valign='top'>\n";
			echo "<td align='center'>".$i++."</td>\n";
			echo "<td align='center'>".$list['title']."</td>\n";
			echo "<td>";
	   		if (!preg_match("/\.html$/",$list['path'])){
	  			$list['path'] .= ".html";
	  		}		
			echo "/". $list['path'];
			echo "</td>";
			echo "<td align='center'>".$list['shortdesc']."</td>\n";
			
			if($list['activate']==1) 
				$activate = 'active';
			else 
				$activate = 'inactive';
				
			echo "<td align='center'>". $activate."</td>\n";
			echo "<td align='center'>";
			echo anchor('cevent/edit/'.$list['event_id'],'edit');
			echo " | ";
			echo anchor('cevent/delete/'.$list['event_id'],'delete',array('class'=>'delete-item'));
			echo "</td>\n";
			echo "</tr>\n";
		}
		echo "</tbody>\n</table>";
	}
	
	// Student Results
	echo '<h2> Student Results </h2><br>';
	$studresults = $this->MStudResult->getAllStudResults();
	if ( count($studresults) )
	{
		echo '<table cellpadding="0" cellspacing="0" border="0" class="bordered-table zebra-striped" id="example">';
		echo "<thead>\n<tr valign='top'>\n";
		echo "<th>No</th>\n<th>Result type</th><th>Image</th><th>Semester</th><th>Shift</th><th>Group</th><th>Batch</th><th>Year</th><th>Activate</th><th>Actions</th>\n";
		echo "</tr>\n</thead>\n<tbody>\n";
		$i = 1;
		foreach ($studresults as $key => $list){
			echo "<tr valign='top'>\n";
			echo "<td align='center'>".$i++."</td>\n";
			echo "<td align='center'>".$list['result_type']."</td>\n";
			echo "<td align='center'><img title='view image' class='img-popup' style='style:width:80px; height:80px;'  src=".base_url().'images/studresult/'.$list['result_src']." /></td>\n";
			echo "<td align='center'>".$list['semester']."</td>\n";
			echo "<td align='center'>".$list['title']."</td>\n";
			echo "<td align='center'>".$list['group']."</td>\n";
			echo "<td align='center'>".$list['batch']."</td>\n";
			echo "<td align='center'>".$list['year']."</td>\n";
			
			if($list['activate']==1) 
				$activate = 'active';
			else 
				$activate = 'inactive';
				
			echo "<td align='center'>". $activate."</td>\n";
			echo "<td align='center'>";
			echo anchor('cstudresult/edit/'.$list['student_result_id'],'edit');
			echo " | ";
			echo anchor('cstudresult/delete/'.$list['student_result_id'],'delete',array('class'=>'delete-item'));
			echo "</td>\n";
			echo "</tr>\n";
		}
		echo "</tbody>\n</table>";
	}
?>